package com.xb.system.controller;

import com.xb.model.req.RequestDto;
import com.xb.system.service.UserInfoQueryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @author wjh
 * @create 2024-08-05 10:44
 */
@Api(tags = "数据查询转换")
@RestController
@RequestMapping("/admin/system/query")
public class QueryController {
    @Autowired
    private UserInfoQueryService userInfoQueryService;

    @Value("${path.output}")
    private String outputFilePath;
    @GetMapping("/query")
    public List<String> query(
            @ApiParam(value = "主行业") @RequestParam(required = false) String primaryIndustry,
            @ApiParam(value = "公司行业") @RequestParam(required = false) String companyIndustry,
            @ApiParam(value = "公司地址") @RequestParam(required = false) String companyAddress,
            @ApiParam(value = "公司城市") @RequestParam(required = false) String companyCity,
            @ApiParam(value = "公司州") @RequestParam(required = false) String companyState
    ) {
        // 创建 RequestDto 并设置查询条件
        RequestDto requestDto = new RequestDto();
        requestDto.setPrimaryIndustry(primaryIndustry);
        requestDto.setCompanyIndustry(companyIndustry);
        requestDto.setCompanyAddress(companyAddress);
        requestDto.setCompanyCity(companyCity);
        requestDto.setCompanyState(companyState);

        // 调用 service 方法，并返回文件路径
        return userInfoQueryService.queryAndGenerateExcel(requestDto, outputFilePath);
    }

}
